/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biofilter.util;

import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author qvh
 */
public class StringUtilTest {

    public StringUtilTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of splitOnSpaces method, of class StringUtil.
     */
    @Test
    public void testSplitOnSpaces() {
        try {
            System.out.println("splitOnSpaces");
            String line = "test1 test2  test3\ttest4"; //note the tab is not split!
            int expectedElements = 3;
            StringUtil instance = new StringUtil();
            String[] expResult = {"test1", "test2", "test3\ttest4"};
            String[] result = instance.splitOnSpaces(line, expectedElements);
            assertEquals(expResult[0], result[0]);
            assertEquals(expResult[1], result[1]);
            assertEquals(expResult[2], result[2]);
        } catch (ParseException ex) {
            Logger.getLogger(StringUtilTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Test
    public void testSplitOnTab() {
        try {
            System.out.println("splitOntab");
            String gffline = "CP000568\tGenBank\tCDS\t104\t1723\t0\t1\t.\tLocus tag: Cthe_0001;Product: Recombinase;color AA0000;";
            int expectedElements = 9;
            StringUtil instance = new StringUtil();
            String[] expResult = {"CP000568", "GenBank", "CDS", "104", "1723", "0", "1", ".", "Locus tag: Cthe_0001;Product: Recombinase;color AA0000;"};
            String[] result = instance.splitOnTab(gffline, expectedElements);
            assertEquals(expResult[0], result[0]);
            assertEquals(expResult[1], result[1]);
            assertEquals(expResult[2], result[2]);
            assertEquals(expResult[3], result[3]);
            assertEquals(expResult[4], result[4]);
            assertEquals(expResult[5], result[5]);
            assertEquals(expResult[6], result[6]);
            assertEquals(expResult[7], result[7]);
            assertEquals(expResult[8], result[8]);
        } catch (ParseException ex) {
            Logger.getLogger(StringUtilTest.class.getName()).log(Level.SEVERE, null, ex);
        }

    }



}